% %load data
% close all
% load fisheriris
% inds = ~strcmp(species,'setosa');
% X = meas(inds,3:4);
% y = species(inds);
% 
% SVMModel = fitcsvm(X,y,'KernelFunction','rbf')
% classOrder = SVMModel.ClassNames
% 
% sv = SVMModel.SupportVectors;
% figure
% gscatter(X(:,1),X(:,2),y)
% hold on
% plot(sv(:,1),sv(:,2),'ko','MarkerSize',10)
% legend('versicolor','virginica','Support Vector')
% 
% CVSVMModel = crossval(SVMModel);
% classLoss = kfoldLoss(CVSVMModel)
% hold off
% 
% %%
% d = 0.01;
% [x1Grid,x2Grid] = meshgrid(min(X(:,1)):d:max(X(:,1)),...
%     min(X(:,2)):d:max(X(:,2)));
% xGrid = [x1Grid(:),x2Grid(:)];
% 
% % Scores = zeros(N,numel(classes));
% [label,score] = predict(SVMModel,xGrid);
% % scores = score(:,2);
% label1 = strcmp(label,label{1,1});
% 
% 
% h(1:2) = gscatter(xGrid(:,1),xGrid(:,2),label,...
%     [0.1 0.5 0.5; 0.5 0.1 0.5]);
% hold on
% h(3:4) = gscatter(X(:,1),X(:,2),y);
% xlabel('Petal Length (cm)');
% ylabel('Petal Width (cm)');
% legend(h,{'versicolor region','virginica region',...
%     'observed versicolor','observed virginica'},...
%     'Location','Northwest');
% axis tight
% hold off
%%
% test acf for vnibor
% 
% close all;
% [val text raw] = xlsread('VNIBOR',6);
% 
% vnibor = val(:,1);
% cpi = val(:,3);
% 
% ma5cpi = (cpi(1:end-4)+cpi(2:end-3) + cpi(3:end-2)+cpi(4:end-1)+cpi(5:end))/5;
% 
% vndusd = val(:,2);
% dates = datenum(text(2:end,1),'m/dd/yyyy');
% 
% dvnibor = vnibor(2:end) - vnibor(1:end-1);
% dcpi = cpi(2:end)./ cpi(1:end-1)-1;
% 
% figure(1)
% hold all;
% subplot(2,2,1); autocorr(vnibor)
% title('Auto correlation for VNIBOR')
% subplot(2,2,2); autocorr(dvnibor)
% title('Auto correlation for 1st difference VNIBOR')
% subplot(2,2,3); parcorr(vnibor)
% title('Partial correlation for VNIBOR')
% subplot(2,2,4); parcorr(dvnibor)
% title('Partial correlation for 1st difference VNIBOR')
% hold off
% 
% figure(2);
% hold on;
% subplot(2,1,1);crosscorr(cpi,vnibor)
% title('Cross correlation vnibor cpi');
% subplot(2,1,2);crosscorr(dcpi,dvnibor)
% title('Cross correlation 1st difference vnibor cpi');
% hold off;
% 
% 
% % dvndusd = vndusd(2:end) - vndusd(1:end-1);
% % figure(3);
% % hold on;
% % subplot(2,1,1);crosscorr(vndusd,vnibor)
% % title('Cross correlation vndusd vnibor');
% % subplot(2,1,2);crosscorr(dvndusd,dvnibor)
% % title('Cross correlation 1st difference vndusd vnibor');
% % hold off;
% 
% 
% %%
% close all;
% % [val text raw] = xlsread('VNIBOR',7);
% 
% vnibor = val(:,1);
% gdp = val(:,4);
% dvnibor = vnibor(2:end) - vnibor(1:end-1);
% dgdp = gdp(2:end)./gdp(1:end-1)-1;
% 
% 
% figure(2);
% hold on;
% 
% subplot(2,1,1);crosscorr(gdp,vnibor)
% title('Cross correlation vnibor M2 gdp');
% subplot(2,1,2);crosscorr(dgdp,dvnibor)
% title('Cross correlation 1st difference nominal vnibor');
% hold off;


